/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package merlion.scm.rmpm.entity;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import merlion.frm.bpm.entity.SupplierInvoice;
import merlion.scm.icm.entity.WarehouseLocation;

/**
 *
 * @author Kenn
 */
@Entity
public class RawMaterialInventoryBatch implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String batchNo;
    private Double quantity;
    private Double quantityAvailable;
    private Timestamp dateOrdered;
    private Timestamp dateExpired;
    @ManyToOne(targetEntity = RawMaterialInventoryRecord.class, cascade = {CascadeType.ALL}, fetch = FetchType.EAGER)
    private RawMaterialInventoryRecord inventory;
    @OneToMany(targetEntity = WarehouseLocation.class, cascade = {CascadeType.ALL}, fetch = FetchType.EAGER)
    private List<WarehouseLocation> locations;
    @ManyToOne(targetEntity = GoodsReceipt.class, cascade = {CascadeType.ALL}, fetch = FetchType.EAGER)
    private GoodsReceipt goodsReceipt;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getBatchNo() {
        return batchNo;
    }

    public void setBatchNo(String batchNo) {
        this.batchNo = batchNo;
    }

    public Timestamp getDateExpired() {
        return dateExpired;
    }

    public void setDateExpired(Timestamp dateExpired) {
        this.dateExpired = dateExpired;
    }

    public Timestamp getDateOrdered() {
        return dateOrdered;
    }

    public void setDateOrdered(Timestamp dateOrdered) {
        this.dateOrdered = dateOrdered;
    }

    public Double getQuantity() {
        return quantity;
    }

    public void setQuantity(Double quantity) {
        this.quantity = quantity;
    }

    public Double getQuantityAvailable() {
        return quantityAvailable;
    }

    public void setQuantityAvailable(Double quantityAvailable) {
        this.quantityAvailable = quantityAvailable;
    }

    public RawMaterialInventoryRecord getInventory() {
        return inventory;
    }

    public void setInventory(RawMaterialInventoryRecord inventory) {
        this.inventory = inventory;
    }

    public List<WarehouseLocation> getLocations() {
        return locations;
    }

    public void setLocations(List<WarehouseLocation> locations) {
        this.locations = locations;
    }

    public GoodsReceipt getGoodsReceipt() {
        return goodsReceipt;
    }

    public void setGoodsReceipt(GoodsReceipt goodsReceipt) {
        this.goodsReceipt = goodsReceipt;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof RawMaterialInventoryBatch)) {
            return false;
        }
        RawMaterialInventoryBatch other = (RawMaterialInventoryBatch) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "merlion.scm.rmpm.entity.RawMaterialInventoryBatch[ id=" + id + " ]";
    }
}
